#include <bits/stdc++.h>
using namespace std;
int n;
int oneh,twoh,w;
int sx[100005];
int isout[100005];

int gs(int x){
    if(sx[1]==sx[x]) return -822; //cut
    for(int i = x-1;i>=1;i--){
        if(isout[i]==0 && sx[i]<sx[x]){
            //have
            return i;
        }
    }
    //have no
    return -822;
}

int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    scanf("%d",&n);
    int ans = n;
    for(int i = 1;i<=n;i++){
        scanf("%d",&sx[i]); //every so sxi;
        //special
        if(sx[i]==1) oneh++;
        if(sx[i]==2) twoh++; 
    }
    if(oneh+twoh==n){
        if(twoh>=oneh){
            printf("%d",twoh);
        }else{
            printf("%d",oneh);
        }
        return 0;
    }
    sort(sx+1,sx+1+n);
   
    for(int i = 1;i<=n;i++){
        if(gs(i)!=-822){
            //can
            isout[gs(i)] = 1;
            ans--;

        }

    }
    printf("%d",ans);
    fclose(stdin);
    fclose(stdout);
    return 0;
}